package com.chhh.cranelease.mapper;

import com.chhh.cranelease.entity.CarInfo;
import com.chhh.cranelease.entity.Staff;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface BaseInfoMapper {
    // 查询所有吊车
    List<CarInfo> selectAllCarInfo();
    @Select("insert into carinfo (c_num,c_brand,c_model,c_create,c_buytime,c_buy,c_money,c_people) values (#{c_num},#{c_brand},#{c_model},#{c_create},#{c_buytime},#{c_buy},#{c_money},#{c_people})")
    void insertNewCar(CarInfo carInfo);

    @Update("update carinfo set c_num=#{c_num},c_brand=#{c_brand},c_model=#{c_model},c_create=#{c_create},c_buytime=#{c_buytime},c_buy=#{c_buy},c_money=#{c_money},c_people=#{c_people} where c_id=#{c_id}")
    void updateThisCar(CarInfo carInfo);

    @Delete(" <script>"+"delete from carinfo where c_id in" +
            "    <foreach collection=\"array\" item=\"id\" separator=\",\" open=\"(\" close=\")\">" +
            "        #{id}" +
            "    </foreach></script>")
    void deleteThoseCar(Integer[] c_id);

    // 查询所有驾驶员
    @Select( "select * from staff")
    List<Staff> selectAllDriver();
}
